class Solution {
public:
    vector<int> stk;
    vector<vector<int>> ans;
    vector<int> hash;
    void dfs(vector<int>& nums,int depth,int maxDepth)
    {
        if(depth==maxDepth)
        {
            ans.push_back(stk);
            return;
        }
        vector<int> vhash(22);
        for(int i=0;i<maxDepth;i++)
        {
            if(!hash[i])//记录第i个字符是否用过
            {
                if(vhash[nums[i]+10]==0)
                {
                    vhash[nums[i]+10]=1;
                    hash[i]=1;
                    stk.push_back(nums[i]);
                    dfs(nums,depth+1,maxDepth);
                    stk.pop_back();
                    hash[i]=0;
                }
            }
        }
    }
    vector<vector<int>> permute(vector<int>& nums) {
        stk.clear();
        hash.resize(10);
        dfs(nums,0,nums.size());
        return ans;
    }
};